<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>{$pagetitle}</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="/static/admin/layui/css/layui.css" media="all">
	<link rel="stylesheet" href="/static/admin/style/admin.css" media="all">
	<link rel="stylesheet" href="/static/admin/style/global.css" media="all">
	<!--select2 js start-->
	<link rel="stylesheet" href="/static/select2/select2.css" media="all">
	<!--select2 js end-->
	<link rel="stylesheet" href="/static/fancybox3/jquery.fancybox.min.css" media="all">
	<link rel="stylesheet" href="/static/admin/style/model38.css" media="all">
</head>
<body>

<div class="layui-fluid">
	<div class="layui-card">

		<div class="layui-form-header">
			<div class="header-left" style="width:70%">
				<div class="layui-inline set-select2">
					<select name="catid" class="select2" lay-ignore style="min-width:220px;" onchange="goLink(this)">{$catOption|raw}</select>
					<a class="layui-btn {$state=='0'?'':'layui-btn-primary'}" href="{:url('index',['catid'=>$cat['catid']])}"><i class="layui-icon layui-icon-ok-circle"></i> 待发布({$DataCount.index})</a>
					<a class="layui-btn {$state=='1'?'':'layui-btn-primary'}" href="{:url('index',['catid'=>$cat['catid'],'state'=>1])}"><i class="layui-icon layui-icon-ok-circle"></i> 已发布({$DataCount.Published})</a>
					<a class="layui-btn {$state=='readyCheck'?'':'layui-btn-primary'}" href="{:url('index_cache',['catid'=>$cat['catid'],'state'=>'readyCheck'])}"><i class="layui-icon layui-icon-fonts-clear"></i> 待他人审核({$DataCount.readyCheck})</a>
					<a class="layui-btn {$state=='notCheck'?'':'layui-btn-primary'}" href="{:url('index_cache',['catid'=>$cat['catid'],'state'=>'notCheck'])}"><i class="layui-icon layui-icon-close"></i> 审核不通过({$DataCount.notCheck})</a>
					<a class="layui-btn {$state=='readyCheckPublic'?'':'layui-btn-primary'}" href="{:url('index_cache',['catid'=>$cat['catid'],'state'=>'readyCheckPublic'])}"><i class="layui-icon layui-icon-fonts-clear"></i> 审核公海({$DataCount.readyCheckPublic})</a>
					<a class="layui-btn {$state=='draft'?'':'layui-btn-primary'}" href="{:url('index_cache',['catid'=>$cat['catid'],'state'=>'draft'])}"><i class="layui-icon layui-icon-edit"></i> 我的草稿({$DataCount.draft})</a>
					<a class="layui-btn {$state=='public'?'':'layui-btn-primary'}" href="{:url('index_cache',['catid'=>$cat['catid'],'state'=>'public'])}"><i class="layui-icon layui-icon-edit"></i> 创作公海({$DataCount.public})</a>
					<a class="layui-btn {$state=='recycle'?'':'layui-btn-primary'}" href="{:url('index_cache',['catid'=>$cat['catid'],'state'=>'recycle'])}"><i class="layui-icon layui-icon-delete"></i> 回收站({$DataCount.recycle})</a>
				</div>
			</div>

			<div class="header-right" style="width:30%;">
				<div class="layui-inline">
					{if $Request.param.openSearch}
					<a href="{:url('',['catid'=>$cat['catid'],'openSearch'=>0,'state'=>$state])}" class="layui-btn layui-btn-primary layuiadmin-btn-list"><i class="layui-icon layui-icon-up"></i> 关闭搜索</a>
					{else /}
					<a href="{:url('',['catid'=>$cat['catid'],'openSearch'=>1,'state'=>$state])}" class="layui-btn layui-btn-primary layuiadmin-btn-list"><i class="layui-icon layui-icon-down"></i> 展开搜索</a>
					{/if}
					{if !$state || $state=="readyCheck" || $state=="draft"}
					<a class="layui-btn layui-btn-primary layuiadmin-btn-list iframe" href="{:url('InfoImport/index',['catid'=>$cat['catid'],'state'=>$state])}" data-width="100%" data-height="100%"><i class="layui-icon layui-icon-app"></i> 导入</a>
					{/if}
					<a class="layui-btn" href="{:url('add',['catid'=>$cat['catid']])}"><i class="layui-icon layui-icon-addition"></i> 增加信息</a>
				</div>
			</div>
			<div class="clear"></div>
			{if $Request.param.openSearch}
			<form action="{:url()}" method="get">
				<input type="hidden" name="catid" value="{$cat.catid}" />
				<input type="hidden" name="openSearch" value="1" />
				<input type="hidden" name="state" value="{$state}" />
				<div  class="layui-form layui-form-item info-search">
					<div class="layui-inline search-field">
						<label class="layui-form-label">
							<select lay-ignore name="searchField">
								{foreach $SearchFieldInc as $v}
								<option value="{$v.field}" {if $Request.param.searchField==$v.field}selected{/if}>{$v.name}</option>
								{/foreach}

							</select>
						</label>
						<label class="layui-form-label" style="width: 80px;">
							<select lay-ignore name="searchFilter">
								<option value="like" {if $Request.param.searchFilter=='like'}selected{/if}>包含</option>
								<option value="notlike" {if $Request.param.searchFilter=='notlike'}selected{/if}>不包含</option>
								<option value="all" {if $Request.param.searchFilter=='all'}selected{/if}>完全匹配</option>
								<option value="eq" {if $Request.param.searchFilter=='eq'}selected{/if}>等于</option>
								<option value="neq" {if $Request.param.searchFilter=='neq'}selected{/if}>不等于</option>
								<option value="gt" {if $Request.param.searchFilter=='gt'}selected{/if}>大于</option>
								<option value="egt" {if $Request.param.searchFilter=='egt'}selected{/if}>大于等于</option>
								<option value="lt" {if $Request.param.searchFilter=='lt'}selected{/if}>小于</option>
								<option value="elt" {if $Request.param.searchFilter=='elt'}selected{/if}>小于待于</option>
							</select>
						</label>
						<div class="layui-input-inline">
							<input type="text" name="keywords" value="{$Request.param.keywords}" placeholder="请输入" autocomplete="off" class="layui-input">
						</div>
					</div>

					<div class="layui-inline" style="float: right; width: auto; margin-right: 0px;">
						<button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search">
							<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> 开始搜索
						</button>
						<a href="{:url('',['catid'=>$cat['catid'],'openSearch'=>0])}" class="layui-btn layui-btn-primary layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search">
							<i class="layui-icon layui-icon-close layuiadmin-button-btn"></i> 关闭搜索功能
						</a>
					</div>
				</div>
			</form>

			{/if}


		</div>



		<div class="layui-card-body">
			<form class="layui-form" action="{:url('updateSort')}" method="post" onsubmit="return save_form(this)" lay-filter="component-form-element">
				<input type="hidden" name="catid" value="{$cat.catid}">
				<input type="hidden" name="remark" value="">









				<div class="XhsBox">
					{foreach $data as $key=>$v}
					<div class="XhsBox_list">
						<div class="XhsBox_list_img">
							<div class="layui-carousel carousel-container">
								<div carousel-item="">
									<?php
									$morepic=str2arr($v['morepic'],"\r\n","||");

									foreach($morepic as $vs){
									?>
									<a data-fancybox="images" href="<?=$vs[1]?>" class="list_img_li"><img src="<?=$vs[1]?>"></a>
									<?php
									}
									?>
								</div>
							</div>
						</div>
						<div class="XhsBox_list_content">
							<div class="list_content_title">{$v.title}</div>
							<div class="list_content_txt">{$v.content|nl2br|raw}</div>
						</div>
						<div class="XhsBox_list_btn">
							<div class="list_btn_left">

								{if $v.state=="draft"||$v.state=='notCheck'}
								<a href="{:url('update',array('catid'=>$v['catid'],'cache_id'=>$v['cache_id']))}" class="btn_left_li" style="margin-left: 40px; background: red">改</a>
								<a href="{:url('delete',array('catid'=>$v['catid'],'cache_ids'=>$v['cache_id']))}" class="btn_left_li ajax_del" style="background: red">删</a>
								{/if}
								{if $v.state=='notCheck'}
								<span style="color:red">原因：{$v.remark}</span>
								{/if}
								{if $v.state=='readyCheck'&&$state=="readyCheckPublic"}
								<a  class="btn_left_li" onclick="un_check_pass({$v['cache_id']})" style="background: red">审核不通过</a>
								{/if}
							</div>
							{if $v.state=='readyCheck'&&$state=="readyCheckPublic"}
							<a href="{:url('checked',array('catid'=>$v['catid'],'cache_ids[]'=>$v['cache_id']))}" data-msg="确定要审核通过吗？" class="list_btn_right ajax_del" >审核<br>通过</a>
							{/if}
							{if $v.state=='public'}
							<a href="{:url('setMy',array('catid'=>$v['catid'],'cache_ids[]'=>$v['cache_id']))}" data-msg="确定要审核通过吗？" class="list_btn_right ajax_detail" >我要<br>认领</a>
							{/if}
						</div>
						<div class="XhsBox_list_botom">
							<span>ID：{$v.id}</span>
							<span>作者：{$v.id}</span>
							<span>审核人：</span>
						</div>


					</div>
					{/foreach}

				</div>






				<div class="listpage">{$pagelist|raw}</div>
			</form>
		</div>

	</div>
</div>

<script src="/static/admin/layui/layui.js"></script>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/globals.js"></script>

<!--select2 js start-->
<script src="/static/select2/select2.js"></script>
<script src="/static/js/jszip.min.js"></script>
<script src="/static/fancybox3/jquery.fancybox.min.js"></script>
<script>
	function applyImgOpts(containerIndex) {
		// 使用 FancyBox 初始化指定序号的 a 元素
		$('[data-fancybox="images-' + containerIndex + '"]').fancybox(imgOpts);
	}
	// 对每个循环体执行初始化
	$('.XhsBox_list').each(function (index) {
		// 为每个循环体内的 a 元素设置唯一的序号
		var containerIndex = index + 1;
		$(this).find('.XhsBox_list_img a').attr('data-fancybox', 'images-' + containerIndex);
		// 初始化 FancyBox
		applyImgOpts(containerIndex);
	});
</script>
<script>
	$('.select2').select2();
	layui.config({
		base: '/static/admin/' //静态资源所在路径
	}).extend({
		index: 'lib/index' //主入口模块
	}).use(['index', 'form','carousel'], function(){
		var $ = layui.$
				,admin = layui.admin
				,element = layui.element
				, carousel = layui.carousel;
		//图片轮播
		$(".XhsBox_list").each(function(index) {
			// 为每个轮播项生成唯一的ID
			var carouselId = "carousel" + (index + 1);
			// 为当前轮播项的carousel-container元素添加唯一的ID
			$(this).find(".carousel-container").attr("id", carouselId);

			// 使用 layui.js 初始化轮播
			carousel.render({
				elem: '#' + carouselId,
				interval: 5000,
				autoplay: false,
				arrow: 'none'
			});
		});
	});

	//复制标题
	$(".CopyTitle").click(function() {
		var currentXhsBoxList = $(this).closest('.XhsBox_list');
		var titleText = currentXhsBoxList.find('.list_content_title').text();
		layer.msg("复制成功");
		copyToClipboard(titleText);
	});

	// 复制内容
	$(".CopyTxt").click(function() {
		var currentXhsBoxList = $(this).closest('.XhsBox_list');
		var contentText = currentXhsBoxList.find('.list_content_txt').text();
		layer.msg("复制成功");
		copyToClipboard(contentText);
	});
	// 下载图片
	$(".DownloadImg").click(function() {
		// 找到当前点击元素所在的父级 XhsBox_list
		var currentXhsBoxList = $(this).closest('.XhsBox_list');
		// 找到当前 XhsBox_list 内所有图片元素
		var images = currentXhsBoxList.find('.list_img_li img');
		var title=currentXhsBoxList.find('.list_content_title').html();

		// 创建 JSZip 实例
		var zip = new JSZip();

		// 遍历每张图片并将其添加到压缩包中
		images.each(function(index) {
			var imageUrl = $(this).attr('src');
			var imageName = 'image_' + (index + 1) + '.jpg';

			// 获取图片数据
			fetch(imageUrl)
					.then(response => response.blob())
					.then(blob => {
						// 将图片添加到压缩包
						zip.file(imageName, blob);

						// 如果是最后一张图片，生成并触发下载链接
						if (index === images.length - 1) {
							zip.generateAsync({ type: 'blob' })
									.then(function (content) {
										// 创建下载链接
										var link = document.createElement('a');
										link.href = URL.createObjectURL(content);
										link.download = title+'.zip';
										link.click();
									});
						}
					});
		});
	});

	function copyToClipboard(text) {
		var tempInput = $('<textarea>');
		$('body').append(tempInput);
		tempInput.val(text).select();
		document.execCommand('copy');
		tempInput.remove();

	}
	//删除
	function this_delete(){
		layer.confirm("此操作会彻底删除，您确定要删除吗？",function(){
			$('.layui-form').attr('action','{:url("delete")}');
			$('.layui-form').submit();
		},function(){layer.closeAll();return false;});
	}
	//审核通过
	function check_pass(){
		$('.layui-form').attr('action','{:url("checked")}');
		$('.layui-form').submit();
	}
	//审核不通过
	function un_check_pass(cache_id){
		layer.prompt({title: '请填写不通过的原因', formType: 2}, function(remark, index){
			layer.close(index);
			ajax_del("{:url('unChecked')}?catid={$cat['catid']}&"+"cache_ids[]="+cache_id+"&remark="+remark);
		});
	}
</script>

</body>
</html>
